package com.smrtcold.dev.plc;

import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType;
import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;

public class TTT {
    //192.168.3.6
    //192.168.3.18
    //192.168.31.255,163

    //12
    public static void main(String[] args) {
        // for (int i = 2; i <50;) {
        S7PLC plc = new S7PLC(EPlcType.S200_SMART, "192.168.1.6");
        plc.checkConnected();
        try {

            for (int i = 0; i < 100; i++) {
                System.err.println("系统运行:  " + plc.readBoolean("Q13.0", "Q13.2"));
//                System.err.println("系统运行:  " + plc.readInt16("Q13.0", "Q13.2"));


//                System.err.println("系统回油温度:  " + plc.readFloat32("VD1456"));
//                System.err.println("系统排气压力: " + plc.readFloat32("VD1448"));
//                System.err.println("压缩机排气温度1 :" + plc.readFloat32("VD1412"));
//                System.err.println("压缩机排气温度2:  " + plc.readFloat32("VD1416"));
//                System.err.println("蒸发压力设定:  " + plc.readFloat32("VD1484"));
//
//                System.err.println("风机冷凝压力设定1:  " + plc.readFloat32("VD1488"));
//                System.err.println("风机冷凝压力设定2:  " + plc.readFloat32("VD1492"));
//                System.err.println("水泵冷凝压力设定1:  " + plc.readFloat32("VD1496"));
//                System.err.println("水泵冷凝压力设定2:  " + plc.readFloat32("VD1500"));
//
//
//                System.err.println("报警温度上限:  " + plc.readFloat32("VD2020"));
//                System.err.println("报警温度下限:  " + plc.readFloat32("VD2024"));
//
//                System.err.println("三号库温度最小值:  " + plc.readFloat32("VD1112"));
//                System.err.println("三号库温度最大值:  " + plc.readFloat32("VD1116"));
//
//                System.err.println("显示中间温度1:  " + plc.readFloat32("VD1072"));
//                System.err.println("显示中间温度2:  " + plc.readFloat32("VD1076"));
//                System.err.println("显示中间温度3:  " + plc.readFloat32("VD1080"));
//                System.err.println("机组1:  " + plc.readBoolean("M13.0"));
//                System.err.println("机组2:  " + plc.readBoolean("M13.2"));
//                System.err.println("三号库启停:  " + plc.readBoolean("M1.0"));
//
//                Thread.sleep(10000);
//                System.err.println("================================================");
//
//                System.err.println("三号库启停:  " + plc.readBoolean("M1.0"));

                Thread.sleep(1000);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        // extracted(plc,"VD1448");
        // i+=2;
        //   }


    }

    private static void extracted(S7PLC plc, String addres) {
        System.err.println("read:" + addres + "=========================");
        try {
            System.err.println("int16:" + plc.readInt16(addres));
        } catch (Exception e) {
        }
        try {
            System.err.println("int32:" + plc.readInt32(addres));//
        } catch (Exception e) {
        }
        try {
            System.err.println("folt32:" + plc.readFloat32(addres));
        } catch (Exception e) {
        }
        try {
            System.err.println("folt64:" + plc.readFloat64(addres));
        } catch (Exception e) {
        }
        try {
            System.err.println("bool:" + plc.readBoolean(addres));
        } catch (Exception e) {

        }
        try {
            System.err.println("string:" + plc.readString(addres));
        } catch (Exception e) {

        }
    }
}
